<script setup lang="ts">
/*
 select,基础款,需要传入options
 */
const emit = defineEmits(['update:modelValue'])
const props = withDefaults(defineProps<{
  modelValue: unknown,
  options: unknown[]
  labelKey?: string
  valueKey?: string,
}>(), {
  labelKey: 'name',
  valueKey: 'id',
})
const value = computed({
  get() {
    return props.modelValue
  },
  set(value) {
    emit('update:modelValue', value)
  }
})

</script>

<template>
  <el-select
      clearable
      v-model="value"
      style="width: 100%"
  >
    <el-option
        v-for="item in props.options"
        :key="item[labelKey]+item[props.valueKey]"
        :label="item[props.labelKey]"
        :value="item[props.valueKey]"
    >
    </el-option>
  </el-select>
</template>

<style scoped lang="scss">

</style>